
 /*
 *create a Subscriber model
 */

var mongoose = require('mongoose');
var database = require('../services/database');

var SubscriberSchema = new mongoose.Schema({
    name: String, // wechat nickname
    phoneNumber: String, // supply #22 
    pictureUrl: String, // wechat 
    region: String, // wechat
    language: String, // wechat
    city: String, // wechat
    openId: String, // wechat
    channelId: String //marketing channel Id encode by QRcode
});

database.model('Subscriber',SubscriberSchema);

exports.Subscriber = database.model('Subscriber');

/*exports.saveSubscriber = function(subscriberEntity){
	subscriberEntity.save(function(err){
		if(err){
			console.log('save failed!');
		}else{
			console.log('save success!');
		}
	});
}

exports.updateSubscriber = function(conditions,update,options){
	subscriberModel.update(conditions,update,options,function(error){
		if(error){
			console.log('update failed!');
		}else{
			console.log('update success!');
		}
	});
}

exports.findSubscriber = function(conditions,projection,options,callback){
	subscriberModel.find(conditions,projections,options,function(error,persons){
		if(error){
			console.log('find err!');
		}else{
			console.log(persons);
			callback(persons);
		}
	});
}

exports.deleteSubscriber = function(conditions){
	subscriberModel.remove(conditions,function(error){
		if(error){
			console.log(error);
		}else{
			console.log("delete success!");
		}
	});
}*/